From 4263177d3515fcb0bf754e2834ced5829775be32 Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 7 Oct 2006 19:43:47 +0000 Subject: [PATCH] Teach KML writer more about Geocaching. Write diff/terr, short description, customize icons by cache type. --- gpsbabel/kml.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gpsbabel/kml.c b/gpsbabel/kml.c index 2efdbb89e..e8f5dec66 100644 --- a/gpsbabel/kml.c +++ b/gpsbabel/kml.c @@ -575,6 +575,36 @@ static void kml_output_tailer(const route_head *header) kml_write_xml(-1, "\n"); } +static +char * +kml_lookup_gc_icon(const waypoint *waypointp) +{ + const char *icon; + char *rb; + + /* This could be done so much better in C99 with designated + * initializers... + */ + switch (waypointp->gc_data.type) { + case gt_traditional: icon = "2.png"; break; + case gt_multi: icon = "3.png"; break; + case gt_virtual: icon = "4.png"; break; + case gt_letterbox: icon = "5.png"; break; + case gt_event: icon = "6.png"; break; + case gt_ape: icon = "7.png"; break; + case gt_locationless: icon = "8.png"; break; // No unique icon. + case gt_suprise: icon = "8.png"; break; + case gt_webcam: icon = "11.png"; break; + case gt_cito: icon = "13.png"; break; + case gt_earth: icon = "earthcache.png"; break; + case gt_mega: icon = "6.png"; break; // No unique icon yet. + default: icon = "8.png"; break; + } + + xasprintf(&rb, "http://www.geocaching.com/images/kml/%s", icon); + return rb; +} + /* * WAYPOINTS */ @@ -600,6 +630,16 @@ static void kml_waypt_pr(const waypoint *waypointp) } else fputs(odesc, ofd); + + if (!global_opts.no_smart_icons && + waypointp->gc_data.diff && waypointp->gc_data.terr) { + fprintf(ofd, " %3.1f/%3.1f", waypointp->gc_data.diff / 10.0, waypointp->gc_data.terr / 10.0); + if (waypointp->gc_data.desc_short.utfstring) { + char *ob = html_entitize(waypointp->gc_data.desc_short.utfstring); + fprintf(ofd, "

%s

\n", ob); + xfree(ob); + } + } kml_write_xml(0, "\n"); xfree(odesc); } @@ -626,6 +666,12 @@ static void kml_waypt_pr(const waypoint *waypointp) fprintf(ofd, "\t \n"); + } else if (!global_opts.no_smart_icons && waypointp->gc_data.diff && waypointp->gc_data.terr) { + char *is = kml_lookup_gc_icon(waypointp); + fprintf(ofd, "\t \n"); + xfree(is); } // Timestamp -- 2.30.2